#-*- coding:utf-8 -*-
from plurk_oauth.PlurkAPI import PlurkAPI as _plurk

"""
這是 Plurk 的介面
"""

plurk = None 

def api(action, args):
    global plurk    
    if action == "use_token":
        try:
            plurk = _plurk(args['consumer_key'], args['consumer_secret'])
            plurk.authorize(args['access_token_key'], args['access_token_secret'])
        except KeyError:
            print "need <consumer_key>, <consumer_secret>, <access_token_key> and <access_token_secret>."
    elif action == "share":
       plurk.callAPI('/APP/Timeline/plurkAdd', {'content':args['content'], 'qualifier':'says'})
    else:
        print action, "is not exist."

if __name__ == "__main__":
   api("use_token", {"consumer_key":"l4RoxqgVnHi0",
                     "consumer_secret":"bBQUQEIGyhxazaMdjhikCBHuXON6gG2A", 
                     "access_token_key":"FJSPg4Dh22B2",
                     "access_token_secret":"d7M8W0IGuquRtxjiNXuYyW33XpcY7qs5"})
   api("share", {"content":"test test"})
